package com.xue566.controller;

import com.xue566.entity.BaseEntity;
import com.xue566.entity.UserEntity;
import com.xue566.service.IUserService;
import com.xue566.util.ResultBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.UUID;

@RestController
@RequestMapping("/user/client")
@Slf4j
@CrossOrigin(value = "*", maxAge = 3600)
public class UserController {

    @Resource
    private IUserService iUserService;

    @GetMapping("/queryList")
    public ResultBody<UserEntity> queryList(){
        BaseEntity userEntity = new UserEntity();
        userEntity.setPageNum(2);
        userEntity.setPageSize(5);
        userEntity.setTrackId(UUID.randomUUID().toString());
        ResultBody<UserEntity> userEntitys = iUserService.queryList(userEntity);
        log.info("学生列表客户端 - [{} - {}]", userEntitys, userEntitys.getQueryList());
        return iUserService.queryList(userEntity);
    }

    @RequestMapping(value = "/selectUser", consumes = "application/json")
    public ResultBody<UserEntity> selectUser(@RequestBody UserEntity userEntity){
        String trackId = UUID.randomUUID().toString();
        userEntity.setTrackId(trackId);
        userEntity.setIsUsed(1);
        ResultBody<UserEntity> userEntitys = iUserService.selectUser(userEntity);
        log.info("查询用户信息：{} - {}", trackId, userEntitys);
        return userEntitys;
    }
}
